package com.xlh.enums.course;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * 笔记类型枚举
 * <p>
 * Created by lx on 2019/1/28.
 */
@Getter
@AllArgsConstructor
public enum NotesTypeEnum {

    COURSEWARE_NOTES(1, "学习课件笔记"),
    PREPARATION_MATERIALS_NOTES(2, "备课材料笔记"),
    EXPERIMENT_NOTES(3, "实验笔记");

    private int code;

    private String message;

    public static NotesTypeEnum getByCode(int code) {
        for (NotesTypeEnum notesTypeEnum : NotesTypeEnum.values()) {
            if (Objects.equals(notesTypeEnum.getCode(), code)) {
                return notesTypeEnum;
            }
        }
        return null;
    }

    public static String getMessageByCode(int code) {
        NotesTypeEnum notesTypeEnum = getByCode(code);
        return notesTypeEnum == null ? null : notesTypeEnum.getMessage();
    }

}
